import { IsBoolean, IsIn, IsInt, IsNotEmpty, IsOptional, IsString, IsUUID, MaxLength } from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { DICT_STATUS_VALUES, type ICreateDictData } from '@nbase/shared';
import { Type } from 'class-transformer';

/**
 * 创建字典数据 DTO
 */
export class CreateDictDataDto implements ICreateDictData {
  @ApiProperty({ description: '字典标签', example: '启用' })
  @IsString()
  @IsNotEmpty()
  @MaxLength(128)
  label!: string;

  @ApiProperty({ description: '字典值', example: '1' })
  @IsString()
  @IsNotEmpty()
  @MaxLength(128)
  value!: string;

  @ApiProperty({ description: '字典ID', example: '550e8400-e29b-41d4-a716-446655440000' })
  @IsUUID()
  @IsNotEmpty()
  dictId!: string;

  @ApiPropertyOptional({
    description: '状态（1.启用 2.禁用）',
    example: 1,
    enum: DICT_STATUS_VALUES,
  })
  @IsOptional()
  @Type(() => Number)
  @IsInt()
  @IsIn(DICT_STATUS_VALUES)
  status?: number;

  @ApiPropertyOptional({ description: '排序', example: 1 })
  @IsOptional()
  @IsInt()
  sort?: number;

  @ApiPropertyOptional({ description: '是否默认', example: false })
  @IsOptional()
  @IsBoolean()
  isDefault?: boolean;

  @ApiPropertyOptional({ description: '描述', example: '启用状态' })
  @IsOptional()
  @IsString()
  @MaxLength(256)
  description?: string;
}

